import time

import yaml
from selenium.webdriver.common.by import By

from page.basePage import basePage

with open(r'D:\PycharmProjects\ecShop\autoTest\driver\elements.yml', 'r' ,encoding='utf-8') as file:
    elements_config = yaml.safe_load(file)

class loginPage(basePage):
    url = "http://localhost:8800/ecshop/"
    login_btn1 = By.XPATH,elements_config['login_page']['login_btn1']
    username_frm = By.XPATH,elements_config['login_page']['username_frm']
    pwd_frm = By.XPATH,elements_config['login_page']['pwd_frm']
    login_btn2 = By.XPATH,elements_config['login_page']['login_btn2']
    msg_context = By.XPATH,elements_config['login_page']['msg_context']

    def click_login1(self):
        self.find_Element(self.login_btn1).click()

    def send_username(self,username):
        self.find_Element(self.username_frm).send_keys(username)

    def send_pwd(self,password):
        self.find_Element(self.pwd_frm).send_keys(password)

    def click_login2(self):
        self.find_Element(self.login_btn2).click()

    def vip_login(self,username,password):
        time.sleep(2)
        self.open(self.url)
        self.click_login1()
        self.send_username(username)
        self.send_pwd(password)
        self.click_login2()






